'use strict';
exports.main = async function(event) {

	//test
	// var event = {
	//     "openid": "10f868823031592047814045dd863d4402bd772349eb8dd9ca61",
	//     "access_token": "bm1jYzEwOTBlMmI2NWY0M2QzODRmNTYwMzUzYjIyMGUzY3wzNjE1fDN8djJ8Mw=="
	// }

	// uniCloud.logger.log("")

	const res = await uniCloud.getPhoneNumber({
		appid: '__UNI__FB289AD', // 替换成自己开通一键登录的应用的DCloud appid
		provider: 'univerify',
		apiKey: '5ef57bdcc238cc5b890bc04a98b75d8e', // 在开发者中心开通服务并获取apiKey
		apiSecret: '847b2e405cd06dfeeea38ef1066bc1bf', // 在开发者中心开通服务并获取apiSecret
		access_token: event.access_token,
		openid: event.openid
	})
	//res => {"code":0,"success":true,"phoneNumber":"191xxxx2490"}

	// 执行入库等操作，正常情况下不要把完整手机号返回给前端
	return {
		code: 0,
		message: '获取手机号成功',
		phoneNumber: res.phoneNumber
	}
}
